// 变量定义
@card-border: rgba(64, 169, 255, 0.3);
@text-color: #fff;
@accent-color: #40a9ff;
@header-height: 24px;
@card-padding: 8px;

.dashboard-card {
  width: 100%;
  height: 100%;
  // 使用border-image实现9切片缩放效果
  border-style: solid;
  border-width: 12px; // 设置足够的边框宽度用于切片
  border-image: url("@/assets/images/png/bg-panel-alert.png") 20 fill stretch;

  // 确保border-image在折叠状态下也正常显示
  &.collapsed {
    height: @header-height;
    border-image: url("@/assets/images/png/bg-panel-alert.png") 20 fill stretch;
  }

  background-color: rgba(0, 0, 0, 0.3);

  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  z-index: 10;
  // 禁止文字选中
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;

  // 折叠状态
  &.collapsed {
    height: 40px;

    // 折叠时只显示标题栏，设置固定高度
    .card-content {
      display: none;
    }

    .card-header {
      border-bottom: none; // 折叠状态下不显示分割线
    }
  }

  .card-header {
    // 标题栏高度固定
    height: @header-height;
    display: flex;
    align-items: center;
    padding-bottom: 4px;
    border-bottom: 1px solid @card-border;

    .panel-icon {
      width: 14px;
      height: 14px;
      object-fit: contain;
      background: url("@/assets/images/png/panel-icon.png") no-repeat;
      background-size: 100% 100%;
    }

    .title-scroll-container {
      flex: 1;
      display: flex;
      overflow: hidden;

      .title-container {
        display: flex;
        align-items: center;
        overflow-x: auto;
        // 隐藏滚动条但保留滚动功能
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;

        /* IE and Edge */
        &::-webkit-scrollbar {
          display: none;
          /* Chrome, Safari and Opera */
        }

        overflow-y: hidden;
        flex: 1;
        scroll-behavior: smooth;
        cursor: grab;

        &:active {
          cursor: grabbing;
        }

        // 显示滚动条以支持横向滚动
        &::-webkit-scrollbar {
          height: 6px;
        }

        &::-webkit-scrollbar-track {
          background: transparent;
        }

        &::-webkit-scrollbar-thumb {
          background-color: rgba(255, 255, 255, 0.3);
          border-radius: 3px;
        }

        &::-webkit-scrollbar-thumb:hover {
          background-color: rgba(255, 255, 255, 0.5);
        }

        .tab-title {
          padding: 0px 8px;
          font-size: 12px;
          color: @text-color;
          cursor: pointer;
          white-space: nowrap;

          &.active {
            font-size: 14px;
            font-weight: bold;
          }
        }
      }
    }

    .close-btn {
      width: 24px;
      height: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      color: @text-color;
      font-size: 18px;
      border-radius: 2px;
      transition: background-color 0.3s ease;
      margin-right: 8px;

      &:hover {
        background-color: rgba(255, 0, 0, 0.2);
      }
    }

    .collapse-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 24px;
      height: 24px;
      color: @accent-color;
      cursor: pointer;
      border-radius: 2px;
      transition: all 0.3s ease;

      .collapse-icon {
        width: 14px;
        height: 14px;
        background: url("@/assets/images/png/arrow-up.png") no-repeat;
        background-size: 100% 100%;
        transition: transform 0.3s ease;
      }

      &.collapsed .collapse-icon {
        transform: rotate(180deg);
      }
    }
  }

  .card-content {
    height: calc(100% - @header-height - 8px);
    color: @text-color;
    font-size: 12px;
    overflow: auto; // 当内容超出高度时显示滚动条

    .loading-container {
      position: absolute;
      width: 100%;
      top: 0;
      bottom: 0;
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: rgba(0, 0, 0, 0.2);
      z-index: 10000;

      &.hidden {
        display: none;
      }

      .loading-icon {
        font-size: 32px;
        color: rgb(65, 132, 248);
      }
    }

    &::-webkit-scrollbar {
      width: @scrollbar-width;
      height: @scrollbar-width;
    }

    &::-webkit-scrollbar-track {
      background-color: @scrollbar-track-color;
      border-radius: @scrollbar-border-radius;
    }
  }
}